package cn.sccl.dirms.topo.discovery.model;

import cn.sccl.common.exception.BusinessException;
import cn.sccl.common.model.BaseModel;

/**
* 自动发现任务与规则的关系表
* 数据库表 T_TOPO_DISCOVER_RE_TASK_RULE 的实体对象
* Created by _minus on 2017-09-25.
*/
public class DiscoverReTaskRule extends BaseModel{
   /**
   *表名
   */
   public final static String TABLE_NAME ="t_topo_discover_re_task_rule";

    private String taskId;//任务id
    private String discoverRuleId;//自动发现规则id

    public void setTaskId(String taskId){
        this.taskId = taskId;
    }

    public String getTaskId(){
        return this.taskId;
    }
    public void setDiscoverRuleId(String discoverRuleId){
        this.discoverRuleId = discoverRuleId;
    }

    public String getDiscoverRuleId(){
        return this.discoverRuleId;
    }

    /**
    * clone一个对象。
    * @param cls 需要克隆的对象类型，只能是当前类的子类
    * @param <T>
    * @return
    * @throws IllegalAccessException
    * @throws InstantiationException
    */
    public <T extends DiscoverReTaskRule> T clone(Class<T> cls) {
       try {
          T t = cls.newInstance();
          t.setId(this.getId());
          t.setDeleteFlag(this.isDeleteFlag());
          t.setCreateTime(this.getCreateTime());
          t.setUpdateTime(this.getUpdateTime());
          /*t.setPosition(this.getPosition());
          t.setUpdateUser(this.getUpdateUser());
          t.setCreateUser(this.getCreateUser());*/
          t.setTaskId(this.getTaskId());
          t.setDiscoverRuleId(this.getDiscoverRuleId());
          return t;
       } catch (Exception e) {
          e.printStackTrace();
          throw new BusinessException("对象克隆失败，请克隆的目标对象是否具有无参的构造函数。", e.getCause());
       }
    }
}